<template>
  <div class="record">
    <el-table :data="tableData" border>
      <el-table-column :label="username" prop="name" align="center"></el-table-column>
      <el-table-column label="券名称" prop="parkingDuration" align="center">
        <template slot-scope="scope">
          {{scope.row.parkingDuration}}小时{{scope.row.sellPrice}}元
        </template>
      </el-table-column>
      <el-table-column label="数量(张)" prop="quantity" align="center"></el-table-column>
      <el-table-column label="发放时间" prop="receiveTime" align="center"></el-table-column>

    </el-table>

    <el-pagination
      :current-page="searchForm.currentPage"
      :page-sizes="[10, 15, 20, 30]"
      :page-size="searchForm.pageSize"
      background
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      align="center"
      style="margin-top:10px;"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
  export default {
    props: ['type'],
    data() {
      return {
        searchForm: {
          currentPage: 1,
          pageSize: 10
        },
        total: 0,
        tableData: [],
        username: '商户名'
      }
    },
    mounted() {
      this.username = this.type == 1 ? '用户名' : '商户名'
      this.searchForm.type = this.type;
      this.getTableData();
    },
    methods: {
      getTableData() {
        this.$axios({
          method: 'get',
          url: '/platform/platform-ticket-park/get-platForm-ticket-record',
          params: this.searchForm
        }).then((res) => {
          if(res.code == 200) {
            this.tableData = res.data.records;
            this.total = res.data.total;
          }
        })
      },

      // 分页修改每页显示条数
      handleSizeChange(val) {
        this.searchForm.pageSize = val;
        this.getTableData();
      },
      // 分页跳转页面
      handleCurrentChange(val) {
        this.searchForm.currentPage = val;
        this.getTableData();
      }
    }
  }
</script>

<style scoped>




</style>
